/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package rmi;

import java.net.NetworkInterface;
import java.net.SocketException;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.util.Collections;
import java.util.Enumeration;

/**
 *
 * @author modesto
 */
public class OpenRMTRMIInterfaceImpl extends UnicastRemoteObject implements OpenRMTRMIInterface {

    public OpenRMTRMIInterfaceImpl() throws RemoteException {
        super();
    }

    @Override
    public String getSystemNetworkInterfaces() throws RemoteException, SocketException {
        Enumeration<NetworkInterface> nets = NetworkInterface.getNetworkInterfaces();
        String netIfs = new String();

        for (NetworkInterface netIf : Collections.list(nets)) {
            netIfs = netIfs + " " + netIf.getName();

            for (NetworkInterface subNetIf : Collections.list(netIf.getSubInterfaces())) {
                netIfs = netIfs + " " + netIf.getName();
            }
        }

        System.out.println(netIfs);
        return netIfs;
    }

}
